<template>
  <view class="colorB">
    <uni-forms ref="queryForm" :modelValue="queryParams" label-width="80px">
      <uni-forms-item name="age" label="订单编号">
        <uni-easyinput v-model="queryParams.orderCode" type="text" placeholder="请输入订单编号" @confirm="handleQuery" />
      </uni-forms-item>

      <uni-forms-item name="age" label="订单状态">
        <!-- <uni-easyinput v-model="queryParams.orderStatus" type="text" placeholder="请选择订单状态" @confirm="handleQuery" /> -->
        <picker mode="selector" :range="orderStatusList" :value="index" :range-key="'dictLabel'" @change="pickerStatus">
          <view>{{index? orderStatusList[index].dictLabel:'请选择订单状态'}}</view>
        </picker>
      </uni-forms-item>

      <uni-forms-item name="age" label="手机号码">
        <uni-easyinput v-model="queryParams.mobileNumber" type="text" placeholder="请输入手机号码" @confirm="handleQuery" />
      </uni-forms-item>

      <uni-forms-item name="age" label="创建时间">
        <!-- <uni-easyinput v-model="createTimeRange" type="text" @confirm="handleQuery" /> -->
        <uni-datetime-picker v-model="createTimeRange" type="daterange" @change="timeChange" />
      </uni-forms-item>
    </uni-forms>
    <view class="btn-flex ">
      <view class="button" @click="handleQuery">搜索</view>
      <view class="button" @click="handReset">重置</view>
    </view>
    <view class="colorB font-13" style="padding:30rpx;" v-for="(item ,index) in orderList" :index="index" :key="index">
      <view class="mainColor border-10" style="border: 1px solid #fff;">
        <view class="flex justify-between align-center padding-10">
          <view class="text color0" style="font-weight: bolder;">
            <navigator :url="'/equipment/orderDetail/orderDetail?orderCode='+ item.orderCode">
              订单编号：{{item.orderCode}}
            </navigator>

          </view>
          <view class=""> {{item.orderStatusDescribe}}</view>
        </view>
        <!-- <view class=" padding-10">订单状态描述：</view> -->
        <!-- <view class=" padding-10">会员昵称：{{item.nickName}}</view> -->
        <!-- <view class=" padding-10">电话号码：{{item.mobileNumber}}</view> -->
        <!-- <view class="flex justify-between align-center padding-10"> -->
        <!-- <view class="">站点类型：{{stationtype(item.stationType)}}</view>
          <view class="">站点状态：{{stationStatus(item.stationStatus )}}</view> -->
        <!-- </view> -->
        <!-- <view class="padding-10">站点：{{item.stationName}}</view> -->
        <!-- <view class="text padding-10">充电桩枪口号：{{item.pileConnectorCode}}</view> -->
        <view class="text padding-10">微信商户订单号：{{item.outTradeNo || '一'}}</view>
        <!-- <view class="text padding-10">微信商户订单号：{{item.outTradeNo === null ? '一':item.outTradeNo}}</view> -->
        <view class="text padding-10">启动方式：{{startMode(item.startMode)}}</view>
        <view class="flex justify-between align-center padding-10 ">
          <view>支付金额：{{item.payAmount=== null ? '一':item.payAmount}}</view>
          <view>{{payMode(item.payMode)}}</view>
          <view>状态：{{payStatus(item.payStatus)}}</view>
        </view>
        <view class="text padding-10">充电度数：{{item.chargingDegree === null ? '一':item.chargingDegree}}</view>
        <view class="flex justify-between align-center padding-10">
          <view>起始soc：{{item.startSoc === null ? '一':item.startSoc}}</view>
          <view>终止soc：{{item.endSoc === null ? '一':item.endSoc}}</view>
        </view>

        <!-- <view class="text padding-10">开始充电时间：{{item.chargeStartTime === null ? '一':item.chargeStartTime}}</view> -->
        <!-- <view class="text padding-10">结束充电时间：{{item.chargeEndTime === null ? '一':item.chargeEndTime}}</view> -->
        <view class="text padding-10">订单总金额：{{item.orderAmount}}</view>
      </view>
    </view>

    <!-- 分页 -->
    <uni-pagination show-icon :page-size="queryParams.pageSize" :current="queryParams.pageNum" :total="total"
      @change="change" />
    <view class="btn-view;mainColor border-10">
      <view class="">
        <text
          class="example-info">当前页：{{ queryParams.pageNum }}，数据总量：{{ total }}条，每页数据：{{ queryParams.pageSize }}</text>
      </view>
      <view class="btn-flex ">
        <button class="button word-btn" hover-class="word-btn--hover" :hover-start-time="20" :hover-stay-time="70"
          @click="add"><text class="word-btn-white">增加10条数据</text></button>
        <button class="button" type="default" @click="reset" style="margin-left: 40rpx;">重置数据</button>
      </view>
    </view>
  </view>
</template>

<script>
  import {
    checkPermi,
    checkRole
  } from "@/utils/permission";
  import {
    listOrder
  } from "@/api/order/order";
  import {
    startMode,
    payMode,
    payStatus,
    orderStatus
  } from '@/common/dict.js'
  export default {
    props: ['stationId'],
    data() {
      return {
        index: null,
        startModeList: [],
        payModeList: [],
        payStatusList: [],
        orderStatusList: [],
        dateDescription: '',
        sumOrderAmount: '',
        sumUsedElectricity: '',
        // 遮罩
        loading: true,
        // 选中数组
        ids: [],
        // 子表选中数据
        checkedOrderDetail: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 订单表格数据
        orderList: [],
        // 订单详情表格数据
        orderDetailList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          orderCode: null,
          mobileNumber: null,
          orderStatus: null,
          stationId: this.stationId,
          startTime: null,
          endTime: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {},
        // 站点列表
        stationList: [],
        // 订单创建时间范围
        createTimeRange: [],
      };
    },
    methods: {
      checkPermi,
      checkRole,
      handReset() { // 重置
        this.queryParams = {}
        this.createTimeRange = []
      },
      timeChange(e) {
        console.log(e);
        this.queryParams.startTime = e[0]
        this.queryParams.endTime = e[1]
      },
      pickerStatus(e) {
        this.index = e.detail.value
        console.log('切换值');
      },
      handleQuery() {
        this.queryParams.pageNum = 1;
        // 获取订单列表
        this.getList();
        // 获取订单总金额
        // this.getOrderTotalData();
      },
      add() {
        this.queryParams.pageSize += 10
        this.getList();
      },
      reset() {
        this.queryParams.pageSize = 10
        this.queryParams.pageNum = 1
        this.getList();
      },
      change(e) {
        console.log(e.current);
        this.queryParams.pageNum = e.current
        this.getList()
      },
      payMode(sim) {
        payMode.then(result => {
          this.payModeList = result
        })
        let str = this.payModeList.find(item => item.dictValue == sim)
        if (str == undefined) {
          return '一'
        } else {
          return str.dictLabel
        }
      },
      payStatus(sim) {
        payStatus.then(result => {
          this.payStatusList = result
        })
        let str = this.payStatusList.find(item => item.dictValue == sim)
        if (str == undefined) {
          return '一'
        } else {
          return str.dictLabel
        }
      },
      startMode(sim) {
        startMode.then(result => {
          this.startModeList = result
        })
        let str = this.startModeList.find(item => item.dictValue == sim)
        if (str == undefined) {
          return '一'
        } else {
          return str.dictLabel
        }
      },
      getList() {
        this.loading = true;
        listOrder(this.queryParams).then(response => {
          this.orderList = response.rows;
          console.log('order里面的参数', this.orderList)
          this.total = response.total;
          this.loading = false;
        });
      },
    },
    created() {
      this.getList()
      orderStatus.then(result => {
        this.orderStatusList = result
      })
    }
  }
</script>

<style lang="scss" scoped>
  .button {
    height: 70rpx;
    margin-left: 10px;
    margin-top: 0;
    line-height: 70rpx;
    color: #fff;
    background-color: #007AFF;
    text-align: center;
    border-radius: 45px;

  }
</style>